package com.wf.it.common.util;

import com.alibaba.fastjson.JSON;
import com.wf.it.common.vo.Result;

import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter;

public class JsonUtil {
    public static void outJson(HttpServletResponse response, Result result){
        PrintWriter out=null;
        try {
            String json = JSON.toJSONString(result);
            response.setContentType("application/json;charset=utf-8");
            out = response.getWriter();
            out.write(json);
        }catch(Exception ex){
            ex.printStackTrace();
            throw new RuntimeException(ex);
        }finally {
            out.flush();
            out.close();
        }
    }
}
